<template>
    <div>
<h1>医生信息显示</h1>
<a href="/addys">医生信息添加</a>
<br> 
<a href="/">病房信息显示</a>
<br>
<a href="/showks">科室信息显示</a>
<br>
<table class="table"> 
            <thead>
                <tr>
                    <td>医生编号</td>
                    <td>姓名</td>
                    <td>头像</td>
                    <td>科室</td>
                    <td>创建日期</td> 
                </tr>
            </thead>
            <tbody>
                 <tr v-for="e in data">
                    <td>{{ e.id }}</td>
                    <td>{{ e.ysName }}</td>
                    <td> <img :src="'https://localhost:7293/'+e.imgUrl" style="height: 60px; width: 60px;"></td>
                    <td>{{ e.ksName }}</td> 
                    <td>{{moment(e.ysDate).format("YYYY-MM-DD") }}</td> 
                </tr>
            </tbody>
        </table>
        一共{{pageinfo.count}}页,一共{{pageinfo.listcount}}条,每页显示{{page.pageSize}}条,当前第{{page.pageIndex}}页
        <input type="button" value="首页" @click="dianjieye(1)">
        <input type="button" value="下一页" @click="dianjieye(2)">
        <input type="button" v-for="e in pageinfo.listcount" :value="e" @click="djy(e)">
        <input type="button" value="上一页" @click="dianjieye(3)">
        <input type="button" value="尾页" @click="dianjieye(4)">
        <input type="number" v-model="page.pageIndex" ><input type="button" value="跳转" @click="tz">
        <select v-model="page.pageSize" @change="yrl">
            <option :value="3">3</option>
            <option :value="5">5</option>
            <option :value="8">8</option>
        </select>
    
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'
import moment  from 'moment';

onMounted(()=>{
    show();
})
//也容量
const yrl=()=>{
    show();
}

//跳转页
const tz=()=>{
    show();
}

const djy=(val:any)=>{
    page.value.pageIndex=val;
    show();
}

//分页
const dianjieye=(val:any)=>{
    if(val==1)
{
    page.value.pageIndex=1;
}
if(val==2)
{
    if(page.value.pageIndex<pageinfo.value.listcount)
{
    page.value.pageIndex+=1
}
}
if(val==3)
{
   if(page.value.pageIndex>1)
{
    page.value.pageIndex-=1
}
}
if(val==4)
{
    page.value.pageIndex=pageinfo.value.listcount;
}

show();
}


const data=ref([{
      "id": 1,
      "keshiid": 2,
      "ysName": "李四",
      "imgUrl": "/img/98764502-b3da-4e7f-b593-a723e669851e1.jpg",
      "ysDate": "2025-05-19T02:18:09.005",
      "ksName": "儿科"
}])
const page=ref({
    pageIndex:1,
    pageSize:3
})

const pageinfo=ref({
    count:0,
    listcount:0,
})


const show=()=>{
    axios.get("/api/HouseYS/ShowYs",{params:page.value}).then(res=>{
        data.value=res.data.listcount
        pageinfo.value.count=res.data.count
        pageinfo.value.listcount=Math.ceil(pageinfo.value.count/page.value.pageSize);
    })
}


</script>

<style scoped>

</style>